package com.njwb.Util;

import com.njwb.pojo.Bill;
import com.njwb.pojo.Supplier;
import com.njwb.pojo.SupplierBill;
import com.njwb.pojo.Users;
import org.apache.ibatis.annotations.Param;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

public interface UtilDaoMapper {
    Users findByUsername(@Param("username") String username);

    Users findByUsernameAndPassRole(@Param("username") String username,
                                    @Param("password") String password,
                                    @Param("role") int role);

    // 查询所有供应商
    ArrayList<Supplier> getAllSupplier();


    ArrayList<Users> getAllUsers();

    ArrayList<Supplier> getSupplierByName(String name);

    ArrayList<Users> getUsersByUsername(String name);

    ArrayList<Bill> getBill(@Param("product_name") String product_name,
                            @Param("is_paid") Boolean is_paid);

    int addUser(@Param("username") String username,
                @Param("password") String password,
                @Param("gender") String gender,
                @Param("age") int age,
                @Param("phone") String phone,
                @Param("address") String address,
                @Param("role") int role);

    int updateUser(@Param("id") int id,
                   @Param("username") String username,
                   @Param("password") String password,
                   @Param("gender") String gender,
                   @Param("age") int age,
                   @Param("phone") String phone,
                   @Param("address") String address,
                   @Param("role") int role);

    int deleteUser(int id);

    int addSupplier(@Param("name") String name,
                    @Param("description") String description,
                    @Param("contact_person") String contact_person,
                    @Param("phone") String phone,
                    @Param("address") String address);

    int updateSupplier(@Param("supplier_id") int supplier_id,
                       @Param("name") String name,
                       @Param("description") String description,
                       @Param("contact_person") String contact_person,
                       @Param("phone") String phone,
                       @Param("address") String address);

    // 删除供应商相关账单
    int deleteBillsBySupplierId(@Param("supplier_id") int supplier_id);

    // 删除供应商
    int deleteSupplier(@Param("supplier_id") int supplier_id);

    // 可选：检查供应商是否存在
    int countSupplierById(@Param("supplier_id") int supplier_id);


    // 查询所有账单
    ArrayList<Bill> getAllBill();


    // 添加账单
    int addBill(@Param("product_name") String product_name,
                @Param("quantity") int quantity,
                @Param("unit") String unit,
                @Param("amount") Double amount,
                @Param("is_paid") Boolean is_paid,
                @Param("supplier_id") int supplier_id,
                @Param("product_description") String product_description,
                @Param("bill_time") Date bill_time);

    // 更新账单
    int modifyBill(@Param("bill_id") int bill_id,
                   @Param("product_name") String product_name,
                   @Param("quantity") int quantity,
                   @Param("unit") String unit,
                   @Param("amount") Double amount,
                   @Param("is_paid") Boolean is_paid,
                   @Param("supplier_id") int supplier_id,
                   @Param("product_description") String product_description,
                   @Param("bill_time") Date bill_time);

    // 删除账单
    int deleteBill(@Param("bill_id") int bill_id);

    // 根据供应商名称获取 supplier_id
    Integer getSupplierIdByName(@Param("name") String name);

    ArrayList<SupplierBill> getSupplierStatistics();
}
